import axios from 'axios'
import api from "./server-api";

var _url = api.ip
// var _url = 'http://47.107.159.133:80'

const orderListApi = (callback) => {
  const url = _url + '/orders/?page=1&limit=10'
  axios.get(url).then(num => {
    callback && callback(num.data)
  })
}

const orderDelApi = (orderId,callback) => {
  const url = _url + '/orders/?ordersId='+orderId
  axios.delete(url).then(num => {
    callback && callback(num.data)
  })
}

const dialogFormVisiblePutApi = (listPut, callback) => {
  var _listPut = new URLSearchParams();
  _listPut.append("orderId",listPut.orderId);
  _listPut.append("orderPrice",listPut.orderPrice);
  _listPut.append("addressId",listPut.addressId);


  const url = _url + '/orders/?' + _listPut;
  axios.put(url).then(num => {
    callback && callback(num.data);
  })
}


export {
  orderListApi, // 自动刷新 只查十条数据
  orderDelApi, //根据id删除
  dialogFormVisiblePutApi, //修改
}
